﻿namespace RadioPlayer
{
    using System;
    using System.Windows.Data;
    using System.Windows.Media.Imaging;

    public class IsPlayingToImageSource : IValueConverter
    {
        #region Methods

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return null;
            try
            {
                var isPlaying = ((bool)value) ? new BitmapImage(new Uri(@"Images\stop.png", UriKind.Relative)) : new BitmapImage(new Uri(@"Images\play.png", UriKind.Relative));
                return isPlaying;
            }
            catch
            {return new BitmapImage();}
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }

        #endregion Methods
    }
}